<template>
	<view style="display: flex;align-items: center;justify-content: space-between;padding: 30upx;">
		<view style="display: flex;flex-direction: column;width: 90%;">
			<text style="color: #333333;font-size: 30upx;">主页访客记录</text>
			<text style="color:#999999;font-size: 24upx;padding-top: 20upx;">开启后，你可以查看自己主页的访客记录。同时你查看他人主页谁也会留下记录。</text>
		</view>
		<switch :checked="isflase" @change="huan" style="padding-left: 10upx;" color="#FF3D3D"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isflase:true
			}
		},
		onLoad() {
			this.$http.getreadprofile().then(res => {
				console.log(res, "微信登录没有走这里吗")
			this.info = res.data
			if(this.info.is_browse_record == 1){
				this.isflase=true
			}else{
				this.isflase=false
			}
		})
		},
		methods: {
			huan(e){
				console.log(e.detail.value)
				
				
				
				if(e.detail.value == true){
					var type_name ='is_browse_record'
					
					var type_id = 1
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title:'设置成功',
								icon:'none'
							})
							this.info.is_message = 1
							this.serviceHotline = res.data.serviceHotline;
						  
						}
					})
				}else{
					var type_name ='is_browse_record'
					
					var type_id = 0
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title:'设置成功',
								icon:'none'
							})
							this.info.is_message = 1
							this.serviceHotline = res.data.serviceHotline;
						  
						}
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
 /deep/.uni-switch-input-checked{
	background-color: #FF3D3D;
}
</style>
